/*
 * 所有路由入口
 */
// import NotFound from '@/views/system/40X/404.vue';
// import NoPrivilege from '@/views/system/40X/403.vue'; 
import TopSimple from '@/layout/top-simple/index.vue'; 
import { MENU_TYPE_ENUM } from '@/constants/system-const';
import menu from '@/assets/menu';
import SideMenu from '@/layout/side-menu/index.vue';

const loginRouters = [
    {
      path: '/login',
      name: 'Login',
      component: () => import('@/views/login.vue'),
      meta: {
        title: '登录',
        hideInMenu: true,
      },
    },
  ];
const menhuRouters = [
    {
      path: '/',
      name: '_home',
      redirect: { name: 'Home' },
      component: TopSimple,
      meta: {
        title: '首页',
        menuType: MENU_TYPE_ENUM.CATALOG.value,
        icon: 'HomeOutlined',
      },
      children: [
        {
          path: '/home',
          name: 'Home',
          meta: {
            title: '首页',
            menuType: MENU_TYPE_ENUM.MENU.value,
            icon: 'HomeOutlined',
            parentMenuList: [{ name: '_home', title: '首页' }],
          },
          component: () => import('@/views/open-info/home.vue'),
        },  
        {
          path: '/shome',
          name: 'shome',
          meta: {
            title: '学生首页',
            menuType: MENU_TYPE_ENUM.MENU.value
          },
          component: () => import('@/views/student/shome.vue'),
        }
      ],
    },
];

function workRoutes() {
  const modules = import.meta.glob('../views/**/**.vue');
    let routes =  {
        path: '/work',
        name: '_work',
        redirect: { name: 'workstation' },
        component: SideMenu,
        meta: {
          title: '工作站',
          menuType: MENU_TYPE_ENUM.CATALOG.value,
          icon: 'HomeOutlined',
        },
        children:[]
    };
    menu.forEach(element => { 
      let route =  {
          path: element.path,
          name: element.name,
          props: element.props,
          meta: {
            title: element.menuName,
            menuType: MENU_TYPE_ENUM.MENU.value,
            icon: element.icon
          }
        };
        let relativePath = `../views${element.component}`;
        route.component = modules[relativePath];
        routes.children.push(route);
    });
    return routes;
}
const wRouters = workRoutes();


export const routerArray = [
    ...loginRouters,
    ...menhuRouters,
    wRouters
];

// { path: '/:pathMatch(.*)*', name: '404', component: NotFound },
// { path: '/403', name: '403', component: NoPrivilege }